<?php

namespace app\models\db;

use Yii;

/**
 * This is the model class for table "t_goods_category".
 *
 * @property string $id
 * @property string $code
 * @property string $name
 * @property string $parent_id
 * @property string $image_url
 * @property integer $is_show
 * @property integer $sort
 * @property string $mini_programs_id
 * @property string $image_id
 * @property integer $is_enabled
 * @property integer $is_deleted
 * @property string $create_datetime
 * @property string $modify_datetime
 *
 * @property GoodsCategoryGoods[] $tGoodsCategoryGoods
 */
class Category extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 't_goods_category';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'mini_programs_id'], 'required'],
            [['is_show', 'sort', 'is_enabled', 'is_deleted'], 'integer'],
            [['create_datetime', 'modify_datetime'], 'safe'],
            [['id', 'parent_id', 'mini_programs_id', 'image_id'], 'string', 'max' => 36],
            [['code', 'name', 'image_url'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'code' => 'Code',
            'name' => 'Name',
            'parent_id' => 'Parent ID',
            'image_url' => 'Image Url',
            'is_show' => 'Is Show',
            'sort' => 'Sort',
            'mini_programs_id' => 'Mini Programs ID',
            'image_id' => 'Image ID',
            'is_enabled' => 'Is Enabled',
            'is_deleted' => 'Is Deleted',
            'create_datetime' => 'Create Datetime',
            'modify_datetime' => 'Modify Datetime',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTGoodsCategoryGoods()
    {
        return $this->hasMany(TGoodsCategoryGoods::className(), ['goods_category_id' => 'id']);
    }
}
